﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head >
    <title>切换部门</title>
    <meta charset="UTF-8"/>
    <link href="../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/easyUI/jquery-1.8.0.min.js" type="text/javascript"></script>
    <script src="../Scripts/QueryString.js" type="text/javascript"></script>
    <!-- 引用通用的js文件. -->
    <script type="text/javascript" src="../Scripts/config.js"></script>
    <script type="text/javascript" src="../Comm/Gener.js"></script>
    <script type="text/javascript" language="javascript" >
        //页面启动函数.
        $(function () {

            $("#Msg").html("<img src='../Img/loading.gif' /><font color=blue>ccbpm 正在获取部门信息.</font>");

            $.ajax({
                type: 'post',
                async: true,
                url: Handler + "?DoType=ChangeDept_Init&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {

                    if (data.indexOf('err@') == 0) {
                        alert(data);
                        return;
                    }
                    data = JSON.parse(data);

                    if (data.length == 0) {
                        $("#Msg").html("您有0个部门不需要切换部门.");
                        return;
                    }

                    if (data.length == 1) {
                        $("#Msg").html("<br><br>您有1个部门<font color=green >(" + data[0].Name + ")</font>不需要切换部门.<br><br>");
                        return;
                    }

                    var html = "<ul>";
                    for (var i = 0; i < data.length; i++) {
                        var dept = data[i];

                        if (dept.CurrentDept == 1)
                            html += "<li ><font color='green'><b>" + dept.Name + "（当前部门）</b></font></li>";
                        else
                            html += "<li onclick=\"ChangeDept_Submit('" + dept.No + "');\" style='font-color:green;' ><u>" + dept.Name + "</u></li>";
                    }

                    html += "</ul>";

                    $("#Msg").html(html);
                    return;
                }
            });
        });

        function ChangeDept_Submit(deptNo) {

            //执行登录..
            $.ajax({
                type: 'post',
                async: true,
                url: Handler + "?DoType=ChangeDept_Submit&DeptNo=" + deptNo + "&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {
                    if (data.indexOf('err@') == 0) {
                        $("#Msg").html("<font color=red>" + data + "</font>");
                        return;
                    }
                    alert(data);
                    window.location.href = "javascript:history.back()";
                }
            });
        }
    </script>
    <style type="text/css">
    table
    {
       border:0px;
       margin-left:30px;
    }
    td
    {
       border:0px;
    }
    li
    {
       font-size:medium;
       cursor:pointer;
    }
    </style>
</head>
<body>
    <form id="cc" >

    <br />
    <br />
    <br />
   <center>

   <fieldset style="width:30%;text-align:left; float:center; margin:50px;"  >
    <legend> 切换部门 - 请选择您要切换的部门 </legend>

    <div id="Msg"  style="margin:50px;"   />

    </fieldset>

     </center>

    </form>
</body>
</html>
